// 导入数据库操作模块
const db = require('../db/index')
// 当前时间
const sd = require('silly-datetime')
exports.feedBack = (req,res)=>{
    // console.log(req.body.fbType);
    // console.log(req.body.fbContent);
    // 得到发送过来的反馈类型、反馈内容、反馈图片
    const fbType=req.body.fbType;
    const fbCon=req.body.fbContent;
    const fbPic = req.body.fbPic;
    // const fbType='其它';
    // const fbCon = 'postman test'
    // const fbPic = 'https://g-search3.alicdn.com/img/bao/uploaded/i4/i2/2207697805232/O1CN01Vd1wrZ1oWJ2MD2p9O_!!0-item_pic.jpg_460x460Q90.jpg_.webp'
    // 得到发表时间
    let fbTime=sd.format(new Date(),'YYYY-MM-DD')
    let params ={
        fbType,
        fbCon,
        fbPic,
        fbTime
    }
    const sqlStr = 'insert into feedback set ?';
    db.query(sqlStr,params,(err,results)=>{
        // 执行SQL语句失败
        if(err) return res.send(err)
        // 调用res.send将信息响应给客户端
        res.send({
            status:200,
            message:'反馈成功',
            result:results
        })
    })
}